/**
*@Author: QWP
*@Description: 首页的共享数据
*@Date 2023-08-14 14:58
*/
import { defineStore } from 'pinia'

interface HomeState {
  expand: boolean, 
  expandKeyPath: object,
  tabMenu: any[],
  allMenu: any[],
  flatMenus: any[],
  activeTabMenu: string,
  sysName: string,
  bodyFontSize: number,
}

export const useHomeStore = defineStore('homeStore', {
  state: (): HomeState => {
    return {
      expand: true, // 侧边菜单展开状态
      expandKeyPath: {}, // 侧边菜单栏展开的路径
      tabMenu: [], // 打开的标签页菜单
      allMenu: [], // 所有菜单
      flatMenus: [], // 扁平菜单
      activeTabMenu: "", // 当前激活的标签页菜单
      sysName: '协同办公平台', // 系统名字
      bodyFontSize: 14, // 14  16  18
    }
  },
  getters: {
    getExpand: (state): boolean => state.expand,
    getTabMenu: (state): any[] => state.tabMenu,
    getActiveTabMenu: (state): string => state.activeTabMenu,
    getSysName: (state): string => state.sysName,
    getBodyFontSize: (state): number => state.bodyFontSize,
  },
  actions: {
    setExpand() {
      this.expand = !this.expand
    },
    setExpandKeyPath(data: object) {
      this.expandKeyPath = data
    },
    setTabMenu(data: any[]) {
      this.tabMenu = data
    },
    setFlatMenus(data: any[]) {
      this.flatMenus = data
    },
    setActiveTabMenu(data: string) {
      this.activeTabMenu = data
    },
    setBodyFontSize(data: number){
      this.bodyFontSize = data
    },
    setAllMenu(data: any[]){
      this.allMenu = data
    },
  },
  persist: true
})